<?php
class lib_sys_setting extends lib_base{
	public $table_name = "qc_sys_setting";
	public $pk = "k";

    public function get_setting($name=''){
        $res = $this->findAll();
        foreach ($res as $key => $val) {
			$result[$val['k']] = unserialize($val['v']);
        }
        if($name) return $result[$name];
        return $result;
    }

    public function set_setting($k,$v){
		return $this->update(array('k'=>$k), array('v'=>serialize($v)));
    }

    public function get_upload_url(){
        $this->config = $this->get_setting('storage');
        $storage = $this->config['default'];
         // 存储域名
        $fileUrl = isset($this->config['engine'][$storage]['domain'])
         ? $this->config['engine'][$storage]['domain'] : '';
        return $fileUrl;
    }
}